﻿#pragma once

#include <iostream>

// CRecipe 对话框
// 处方列表信息显示窗体; 支持可查询处方 显示当前处方详细信息，主动打印;

class CRecipe : public CDialog
{
	DECLARE_DYNAMIC(CRecipe)

public:
	CRecipe(CWnd* pParent = nullptr);   // 标准构造函数
	virtual ~CRecipe();

// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_DLG_REPICE };
#endif

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

	DECLARE_MESSAGE_MAP()

public:
	virtual BOOL OnInitDialog();
	virtual BOOL PreTranslateMessage(MSG* pMsg);

public:
	afx_msg void OnNMDblclkTreeRecipe(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnTvnSelchangedTreeRecipe(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnBnClickedBtnPrint();
	afx_msg LRESULT OnUpdateRecipeTreeNode(WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnUpdateRecipeTree(WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnResetRecipeWindow(WPARAM wParam, LPARAM lParam);

	afx_msg void OnBnClickedBtnSearch();
	afx_msg void OnEnSetfocusEditSerachRecipeid();
	afx_msg void OnSize(UINT nType, int cx, int cy);

public:
	void init();
	void addRecipeInfoNode(std::string patientId,std::string uniqueId);      // 当处理好一条打印信息时，将处方信息添加到已处理列表中;
	void showRecipeInfoInList(std::string recipeInfo); // 解析json字符串，显示处方列表在处方详情中;

private:
	void ChangeSize(UINT nID, int x, int y); // nID 为控件ID, x y 分别为对话框的当前长和宽;
public:
	CTreeCtrl m_CtrlTreeRecipe;
	CListCtrl m_CtrlRecipeInfo; 

	HTREEITEM m_RootFinish;     // 已经处理;
	HTREEITEM m_RootPrepare;    // 预配处方单信息;
	HTREEITEM m_RootDir;        // 直发处方单信息;
	
	CString m_strName;
	CString m_strSex;
	CString m_strAge;
	CString m_strRecipeID;// 待查询的处方ID
	CEdit m_CtrlSearch;
	CRect      m_rect;           // 用于保存原来对话框大小;

};
